package com.learn.rabbitmq.two;

import com.learn.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.Channel;

/**
 * 工作线程 相当于消费者
 */
public class Worker01 {

    //队列名称
    public static final String QUEUE_NAME="hello";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtils.getChannel();

        System.out.println("C3等待接收消息......");
        //接收消息
        channel.basicConsume(QUEUE_NAME,
                true,
                (consumerTag, message) -> {
                    System.out.println("接收到的消息："+new String(message.getBody()));
                },
                (consumerTag) -> {
                    System.out.println(consumerTag+"：消息执行被取消");
                });




    }

}
